package com.xiangyueEducation.uploaderCloud.service.impl;

import com.xiangyueEducation.uploaderCloud.mq.batchImport.BatchImportListener;
import com.xiangyueEducation.uploaderCloud.mq.batchImport.BatchImportProducer;
import com.xiangyueEducation.uploaderCloud.service.BatchImportService;
import com.xiangyueEducation.uploaderCloud.utils.Result;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.io.InputStream;

@Slf4j
@Service
public class BatchImportServiceImpl implements BatchImportService {

    @Autowired
    BatchImportProducer batchImportProducer;

    @Override
    public Result<?> importExcel(MultipartFile file) {
        try(InputStream inputStream = file.getInputStream();
            XSSFWorkbook workbook = new XSSFWorkbook(inputStream))  {
            XSSFSheet sheet = workbook.getSheetAt(0);
            for (Row row : sheet){
                for (Cell cell : row){

                }
            }

        } catch (IOException e) {
            log.info("文件读取流失败");
            throw new RuntimeException(e);
        }
        return null;
    }

}
